﻿/*
    Copyright (C) <2007-2013> Kay Diefenthal

    SimpleRadio is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SimpleRadio is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SimpleRadio.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.MediaCenter.UI;

namespace SimpleRadio
{
    /// <summary>
    /// <see cref="ServiceOffer"/> Class
    /// </summary>
    public class ServiceOffer : ModelItem
    {
        #region Private Fields

        private string _displayName;
        private string _country;
        private string _region;
        private IList _genres;

        #endregion

        #region Constructors

        /// <summary>
        /// Initialize a new Instance of <see cref="ServiceOffer"/> Class.
        /// </summary>
        public ServiceOffer()
        {
            _displayName = string.Empty;
            _country = string.Empty;
            _region = string.Empty;
            _genres = new List<string>();
        }

        /// <summary>
        /// Initialize a new Instance of <see cref="ServiceOffer"/> Class.
        /// </summary>
        /// <param name="displayName">displayName</param>
        /// <param name="country">country <seealso cref="System.String"/></param>
        /// <param name="region">region <seealso cref="System.String"/></param>
        /// <param name="genres">genres <seealso cref="System.Collections.IList"/></param>
        public ServiceOffer(string displayName, string country, string region, IList genres)
        {
            _displayName = displayName;
            _country = country;
            _region = region;
            _genres = genres;
        }

        #endregion

        #region Properties

        /// <summary>
        /// DisplayName is the Name of the Channel 
        /// </summary>
        public String DisplayName
        {
            get { return _displayName; }
            set
            {
                if (_displayName != value)
                {
                    _displayName = value;
                    FirePropertyChanged("DisplayName");
                }
            }
        }

        /// <summary>
        /// Country is the Country of the Channel
        /// </summary>
        public String Country
        {
            get { return _country; }
            set
            {
                if (_country != value)
                {
                    _country = value;
                    FirePropertyChanged("Country");
                }
            }
        }

        /// <summary>
        /// Region is the Region of the Channel
        /// </summary>
        public String Region
        {
            get { return _region; }
            set
            {
                if (_region != value)
                {
                    _region = value;
                    FirePropertyChanged("Region");
                }
            }
        }

        /// <summary>
        /// Genres is the Genres of the Channel
        /// </summary>
        public String Genres
        {
            get
            {
                var value = string.Empty;
                if (_genres != null)
                {
                    switch (_genres.Count)
                    {
                        case 1:
                            value = string.Format("{0}", _genres[0]);
                            break;
                        case 2:
                            value = string.Format("{0}, {1}", _genres[0] , _genres[1]);
                            break;
                        case 3:
                            value = string.Format("{0}, {1}, {2}", _genres[0] , _genres[1] , _genres[2]);
                            break;
                        case 4:
                            value = string.Format("{0}, {1}, {2}, {3},", _genres[0] , _genres[1] ,_genres[2] ,_genres[3]);
                            break;
                        case 5:
                            value = string.Format("{0}, {1}, {2}, {3}, {4}", _genres[0] , _genres[1] ,_genres[2] ,_genres[3] , _genres[4]);
                            break;

                    }
                }
                if ((_genres == null) || (_genres.Count == -1))
                {
                    value = string.Empty;
                }

                return value;
            }
        }

        #endregion
    }
}